﻿Imports System.Transactions
Imports Sistema_InformacionNaviera.BE
Imports Sistema_InformacionNaviera.DALC

Public Class DiasLibresDetalleBC
    Public Function ListaDiasLibresDetalle(ByVal objDLibresDetBE As DiasLibresDetalleBE) As DataTable
        Dim objDLibresDet As DataTable = Nothing
        Dim objDLibresDetDALC As DiasLibresDetalleDALC = Nothing

        objDLibresDetDALC = New DiasLibresDetalleDALC
        objDLibresDet = New DataTable
        objDLibresDet = objDLibresDetDALC.ListaDiasLibresDetalle(objDLibresDetBE)

        Return objDLibresDet
    End Function

    Public Function ValidarBillOfLading(ByVal objDLibresDetBE As DiasLibresDetalleBE) As DiasLibresDetalleBE
        Dim objDLibresDetDALC As DiasLibresDetalleDALC = Nothing
        Dim objDLibDetBE As DiasLibresDetalleBE
        objDLibresDetDALC = New DiasLibresDetalleDALC
        objDLibDetBE = objDLibresDetDALC.ValidarBillOfLading(objDLibresDetBE)

        Return objDLibDetBE
    End Function

    Public Function ValidarContenedor(ByVal objDLibresDetBE As DiasLibresDetalleBE) As DiasLibresDetalleBE
        Dim objDLibresDetDALC As DiasLibresDetalleDALC = Nothing
        Dim objDLibDetBE As DiasLibresDetalleBE
        objDLibresDetDALC = New DiasLibresDetalleDALC
        objDLibDetBE = objDLibresDetDALC.ValidarContenedor(objDLibresDetBE)

        Return objDLibDetBE
    End Function

    Public Function ObtieneCodigo(ByVal objDLibresDetBE As DiasLibresDetalleBE) As List(Of DiasLibresDetalleBE)
        Dim objDLibresDet As List(Of DiasLibresDetalleBE) = Nothing
        Dim objDLibresDetDALC As DiasLibresDetalleDALC = Nothing

        objDLibresDetDALC = New DiasLibresDetalleDALC
        objDLibresDet = New List(Of DiasLibresDetalleBE)()
        objDLibresDet = objDLibresDetDALC.ObtieneCodigo(objDLibresDetBE)

        Return objDLibresDet
    End Function


    Public Function InsertarDiasLibresDet(ByVal objDiaslibresDet As DiasLibresDetalleBE, iTipo As Integer) As Boolean

        Dim objScope As TransactionScope
        objScope = New TransactionScope
        Dim bExito As Boolean = False

        Using objScope
            Try
                Dim objDLibresDetDALC As DiasLibresDetalleDALC = Nothing
                objDLibresDetDALC = New DiasLibresDetalleDALC
                If iTipo = 0 Then
                    objDLibresDetDALC.InsertarDiasLibresCntr(objDiaslibresDet)
                ElseIf iTipo = 1 Then
                    objDLibresDetDALC.InsertarDiasLibresBl(objDiaslibresDet)
                ElseIf iTipo = 2 Then
                    objDLibresDetDALC.InsertarDiasLibresTipoPies(objDiaslibresDet)
                ElseIf iTipo = 3 Then
                    objDLibresDetDALC.InsertarDiasLibresPuerto(objDiaslibresDet)
                ElseIf iTipo = 4 Then
                    objDLibresDetDALC.InsertarDiasLibresPais(objDiaslibresDet)
                ElseIf iTipo = 5 Then
                    objDLibresDetDALC.InsertarDiasLibresArea(objDiaslibresDet)
                End If

                objScope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return bExito
    End Function
End Class
